<!DOCTYPE HTML>
<html>
<head>
    <title>订单详情</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- import start -->
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/vue.js"></script>
    <script type="text/javascript" src="/layer/layer.js"></script>
    <script type="text/javascript" src="/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/js/common.js"></script>
    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/global.css">
    <!-- import end -->
</head>
<body>
    <!-- mine start -->
    <div class="container-fluid mine" id="mine">
        <div class="row">
            <div v-if="userInfo==null" class="col-xs-6">
                <span>东方购物欢迎你，</span>&nbsp;
                <span><u><strong><a href="/login.html">[请登录]</a></strong></u></span>&nbsp;
                <span><u><strong><a href="javascript:void(0)">[免费注册]</a></strong></u></span>
            </div>
            <div v-else>
                <div  class="col-xs-6">
                    <span>东方购物欢迎你，</span>&nbsp;
                    <span><u><strong><a href="javascript:void(0)">[{{userInfo.nickname}}]</a></strong></u></span>&nbsp;
                    <span><u><strong><a href="javascript:void(0)" @click="logout">[退出登录]</a></strong></u></span>
                </div>
                <div class="col-xs-6 text-right">
                    <span><u><strong><a href="/my_orders.html" target="_blank">[我的订单]</a></strong></u></span>&nbsp;
                    <span><u><strong><a href="#" data-toggle="modal" data-target="#addressModal">[我的地址]</a></strong></u></span>&nbsp;
                    <span><u><strong><a href="javascript:void(0)" @click="shopCar">[购物车]</a></strong></u></span>&nbsp;
                </div>
                <!-- Address start -->
                <div class="modal fade" id="addressModal" tabindex="-1" role="dialog" aria-labelledby="addressModal">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="myModalLabel">修改地址</h4>
                            </div>
                            <div class="modal-body">
                                <div class="panel panel-danger" style="background-color:rgba(222,222,222,0.8)">
                                    <div class="panel-heading">
                                        <span>当前地址:</span>
                                        <span>{{userInfo.address}}</span>
                                    </div>
                                    <br>
                                    <div class="panel-body">

                                        <address_select ref="selectAddress"></address_select>

                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                <button @click="updateAddress" type="button" class="btn btn-primary">修改地址</button>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- Address end -->
            </div>
        </div>
    </div>
    <!-- mine end -->

    <!-- header start -->
    <div class="container-fluid header">
        <div class="row">
            <div class="col-xs-12 banner">
                <img src="/img/banner.jpg" />
            </div>
        </div>
    </div>
    <!-- header end -->

    <!-- main start -->
    <div class="container-fluid main" id="orderList">
        <div class="panel panel-default" style="height:100%;background-color:rgba(222,222,222,0.8)">
            <table class="table">
                <thead >
                    <tr>
                        <th>
                            商品
                        </th>
                        <th>
                            单价
                        </th>
                        <th>
                            数量
                        </th>
                        <th>
                            实付款
                        </th>
                        <th>
                            订单状态
                        </th>
                        <th>
                            操作
                        </th>
                    </tr>
                </thead>
                <tbody >
                    <tr v-for="item of orders">
                        <td style="width: 30%">
                            <div style="width: 80px;float:left">
                                <a :href="'/goods_detail.html?goodsId='+item.goods.id">
                                    <img :src="item.goods.goodsImg" width="80px" height="80px"/>
                                </a>

                            </div>
                            <div style="margin-left:90px; text-align: left">
                                <a :href="'/goods_detail.html?goodsId='+item.goods.id">
                                    <p>{{item.goods.goodsName}}</p>
                                    <p>{{item.goods.goodsTitle}}</p>
                                </a>
                            </div>
                        </td>
                        <td>
                            {{item.goods.goodsPrice}}
                        </td>
                        <td>
                            {{item.order.count}}
                        </td>
                        <td>
                            {{item.order.price}}
                        </td>
                        <td>
                            <span v-if="item.order.status==0">未支付</span>
                            <span v-if="item.order.status==1">已支付</span>
                        </td>
                        <td>
                            <a :href="'/order_detail.html?orderId='+item.order.id" class="btn btn-primary btn-lg">查看详情</a>
                        </td>
                    </tr>
                </tbody>
            </table>

            <!-- page start -->
            <div class="container-fluid page">
                <div class="row">
                    <div class="span12">
                        <ul class="pagination">
                            <li>
                                <a href="javascript:void(0)" @click="getOrders(prePage)" v-show="hasPreviousPage" >上一页</a>
                            </li>
                            <li :class="item==currentPage?'active':false" v-for="item of navigatepageNums">
                                <a href="javascript:void(0)" @click="getOrders(item)" >{{item}}</a>
                            </li>
                            <li>
                                <a href="javascript:void(0)" @click="getOrders(nextPage)" v-show="hasNextPage" >下一页</a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <!-- page end -->

        </div>
    </div>
    <!-- main end -->

    <!-- footer start -->
    <footer>
        <div class="container-fluid">
            <div class="row">
                <div class="col-xs-6">
                    <h4><img src="/img/footImg.jpg" width="250" /></h4>
                    <p>我们一直致力于为广大消费者提供更加优质的购物体验！</p>
                </div>
                <div class="col-xs-6">
                    <div class="row">
                        <div class="col-xs-4">
                            <h4>关于</h4>
                            <ul class="list-unstyled">
                                <li><a href="#">关于我们</a></li>
                                <li><a href="#">广告合作</a></li>
                                <li><a href="#">友情链接</a></li>
                            </ul>
                        </div>
                        <div class="col-xs-4">
                            <h4>联系方式</h4>
                            <ul class="list-unstyled">
                                <li><a href="#">新浪微博</a></li>
                                <li><a href="#">电子邮件</a></li>
                                <li><a href="#">留言板</a></li>
                            </ul>
                        </div>
                        <div class="col-xs-4">
                            <h4>特别致谢</h4>
                            <ul class="list-unstyled">
                                <li><a href="https://www.bootcss.com/">BootStrap中文网</a></li>
                                <li><a href="https://cn.vuejs.org/">Vue.js官网</a></li>
                                <li><a href="https://www.tmall.com/">天猫购物</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <ul class="list-inline text-center">
                    <li><a href="http://www.beian.miit.gov.cn/" target="_blank">京ICP备88888888号-8</a></li><li>京公网安备88888888888888</li>
                </ul>
            </div>
        </div>
    </footer>
    <!-- footer end -->
    <script type="text/javascript" src="/js/myvue.js"></script>
    <script>
        new Vue({
            el:"#orderList",
            data:{
                orders:[],
                prePage:1,
                currentPage:1,
                nextPage:2,
                navigatepageNums:[1,2,3,4],
                pages:4,
                hasPreviousPage:true,
                hasNextPage:true
            },
            methods:{
                getOrders:function(page){
                    var self = this;
                    $.ajax({
                        url:"/order/list?page="+page,
                        dataType:"JSON",
                        type:"GET",
                        success:function(data){
                            if(data.code==0){
                                self.orders = data.data.list;
                                self.prePage = data.data.prePage;
                                self.currentPage = data.data.pageNum;
                                self.nextPage = data.data.nextPage;
                                self.navigatepageNums =data.data.navigatepageNums;
                                self.pages = data.data.pages;
                                self.hasPreviousPage = data.data.hasPreviousPage;
                                self.hasNextPage = data.data.hasNextPage;
                            }else{
                                layer.msg(data.msg);
                            }
                        },
                        error:function(){
                            layer.msg("客户端请求有误");
                        }
                    });
                }
            },
            created:function(){
                var page = g_getQueryString("page");
                if(!page){
                    page = this.currentPage;
                }
                this.getOrders(page);
            }
        });
    </script>
</body>
</html>
